package cur.nature.tinyorm.core.bean;

import java.io.Serializable;
import java.util.List;

public class PageBean<T> implements Serializable {
    private static final long serialVersionUID = 8656597559014685635L;
//    @Schema(description = "总记录数")
    private long total;        //总记录数
//    @Schema(description = "结果集")
    private List<T> list;    //结果集
//    @Schema(description = "第几页")
    private long pageNum;    // 第几页
//    @Schema(description = "每页记录数")
    private long pageSize;    // 每页记录数
//    @Schema(description = "总页数")
    private long pages;        // 总页数
//    @Schema(description = "总记录数")
    private long size;        // 当前页的数量 <= pageSize，该属性来自ArrayList的size属性

    public PageBean() {}
    /**
     * 包装Page对象，因为直接返回Page对象，在JSON处理以及其他情况下会被当成List来处理，
     * 而出现一些问题。
     * @param list          page结果
     */
//    public PageBean(List<T> list) {
//        if (list instanceof PageBean) {
//            PageBean<T> page = (PageBean<T>) list;
//            this.pageNum = page.getPageNum();
//            this.pageSize = page.getPageSize();
//            this.total = page.getTotal();
//            this.pages = page.getPages();
//            this.list = page;
//            this.size = page.size();
//        }
//    }


    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public long getPageNum() {
        return pageNum;
    }

    public void setPageNum(long pageNum) {
        this.pageNum = pageNum;
    }

    public long getPageSize() {
        return pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    public long getPages() {
        return pages;
    }

    public void setPages(long pages) {
        this.pages = pages;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }
}
